#pragma once

#include "../../render/components.hpp"
#include "qlib/all.h"
namespace qbe::editing::Clipping {

struct ClippingModel {
  bool inited = false;
  bool exitable = true;
  bool request_exit = false;
  bool key_space_switch_mode = true;          //记录从当前模式按下空格
  bool can_clipping = false;                  //单选判断可以修剪
  std::vector<qlib::Vec2d> pick_line_points;  //多选线工具
  //可视化
  qbe::render::LineMesh pick_line;           //多选线
  qbe::render::LineListMesh clipping_lines;  //修剪的线

  void updatePickLine(std::vector<qlib::Vec2d> points) { pick_line = qbe::render::LineMesh(points); }

  void updateClippingLines(std::vector<std::vector<qlib::Vec2d>> list) { clipping_lines = qbe::render::LineListMesh(list); }

  void updateVisualData(std::vector<qlib::Vec2d> line, std::vector<std::vector<qlib::Vec2d>> list) {
    updatePickLine(line);
    updateClippingLines(list);
  }

  void clear() {
    inited = false;
    key_space_switch_mode = false;
    can_clipping = false;
    clear_visual_data();
  }

  void clear_visual_data() {
    pick_line_points.clear();
    updatePickLine({});
    updateClippingLines({});
  }
};

}  // namespace qbe::editing::Clipping